home *** CD-ROM | disk | FTP | other *** search
/ Commodore Free 23 / Commodore_Free_Issue_23_2008_Commodore_Computer_Club.d64 / t.b guide 8.2 < prev    next >
Text File  |  2023-02-26  |  12KB  |  369 lines

  1. u
  2.  
  3. In the Beginning Chapter 8 Section 2
  4. -------------------------
  5. \Lord Ronin from Q-Link\
  6.  
  7. Don't worry if my explanation of how
  8. that maze is being created doesn't
  9. make a lot of sense, I think that it
  10. is a bit too advanced for this level.
  11. It took me 7 times through the book
  12. working with others to even have a
  13. remote idea on how the process works.
  14. What the important point is that you
  15. can print the chr$ as well as the
  16. reverse. This is done as follows.
  17.  
  18. ?ASC("Z")
  19.  
  20. Press RETURN
  21. 90 will appear on the screen.
  22.  
  23. ?CHR$(92)
  24. Press RETURN
  25. \ will appear on the screen.
  26.  
  27. Try a few of these on your own, there
  28. are books, reference cards and other
  29. places where the lists of the
  30. characters and codes are already
  31. listed. Still it is a way to have a
  32. little fun and get more of a feel for
  33. the system. A way to see the actual
  34. character from the keyboard as well as
  35. finding the ascii value. OK here we
  36. have a time problem, I quote from the
  37. book. "As you probably figured out,
  38. 'ASC' is another function, which
  39. returns the standard 'ASCII' code type
  40. for the character you typed."
  41.  
  42. Early on in this collection of drivel
  43. I said something about the characters
  44. ascii and PETascii. Ascii and PETascii
  45. are different animals, lets not worry
  46. what the initials stand for in this
  47. case, only that there is a gigantic
  48. difference. Saying that we come to the
  49. point of what is really "Standard".
  50. Because, obviously there isn't a
  51. "real" standard, making a ruling now,
  52. PETascii is the Commodore standard and
  53. normal ascii is the standard used by
  54. the IBM pc! Clear for that, PETascii
  55. is what we are learning about, so it
  56. must be the only standard we need
  57. right? And yes I am biased towards the
  58. C=.
  59.  
  60. Going by the book we just moved into
  61. Chapter 5 "Advanced Colour and Graphic
  62. Commands" Lets jump right in, even
  63. with the personal thought that we
  64. aren't really that advanced. I mean I
  65. have never thought that I was that
  66. "Advanced" any time I had reached this
  67. point in the manual. Here they start
  68. you off telling you the colours for
  69. the control and the C= key, we already
  70. covered this a bit earlier on in the
  71. series. You remember the bit about
  72. using the Control key and the number
  73. keys to make the first 8 colours, then
  74. the C= key and the numbers for the
  75. next 8 colours. In order to illustrate
  76. this in the book there is a little one
  77. line programme they want you to enter
  78. and run.
  79.  
  80. 10 ?"RAINBOW"
  81.  
  82. What they want you to do is change the
  83. colour for each letter by pressing the
  84. control and keys 1-7. Doing that in
  85. front of each letter and using the
  86. numbers in that order, yeah they want
  87. control and 1 before the R control and
  88. 7 before the W. Then run the programme
  89. and you will see the word printed in
  90. different coloured letters on screen.
  91.  
  92.  The rest of page 57 is taken up with
  93. a chart that shows you the character
  94. gfx symbol that appears in a print
  95. statements, all 16 of them. Sorry the
  96. writing tool I am using doesn't have
  97. all those gfx characters in the set,
  98. since I am using the upper and lower
  99. case letters. You can experiment on
  100. that at this point if you don't have a
  101. list, creating your own list; OK I
  102. don't bother with that myself. Only
  103. look at the word on the number key for
  104. the colour and press that key in the
  105. print statement, but I am a lamer
  106. programmer and lazy to boot. At this
  107. point in the book and therefore the
  108. series of articles we are going to run
  109. into this symbol problem in different
  110. ways, Seen by this short program they
  111. have you type in.
  112.  
  113. new
  114. 10 ?CHR$(147): REM CLEAR HOME
  115. 20 ?CHR$(30);"CHR$(30) CHANGES ME TO ?"
  116.  
  117. RUN
  118.  
  119. Well you don't have a chart of the
  120. character strings, do you? I'm working
  121. on the assumption that you don't, at
  122. least at this moment. I believe that
  123. there is a place online that has the
  124. manual for Down Loading. This list of
  125. codes are in the appendix in he back
  126. of the manual and in the Programmers
  127. Reference Guide. As well as in some of
  128. the type in books I have seen. Those
  129. of you who do have these charts, they
  130. are the ones that are ladled "Screen
  131. Display Codes", and the other one is
  132. "Ascii and CHR$ codes. You are lucky
  133. and I'd like you to thumb to that
  134. section from time to time. Right now
  135. we are dealing with the "Ascii and
  136. CHR$ Codes" one.
  137.  
  138.  OK back to that little programme.
  139.  
  140. Line 10
  141. This gives you the CHR$ for the
  142. shifted clear home, Note that the
  143. number is always in the () symbols.
  144. Well my level and understanding of
  145. programming has me looking at that and
  146. counting the spaces. Counting the
  147. print command as the ? symbol, that is
  148. 9 spaces taken up. Using the ? and the
  149. shifted clear home in the quotes takes
  150. up 4 spaces. Seems this last style is
  151. more effective in spaces. More
  152. experienced programmers can tell me if
  153. I am right or wrong on this thought. I
  154. have seen the chr$(147) in type in
  155. programmes and substituted the shifted
  156. clear home, didn't appear to me to do
  157. anything different in the prg.
  158.  
  159.  Line 20
  160. This will print that character string
  161. and then the words in the quotes
  162. notice that there is nothing for you
  163. to do for a real answer, which is
  164. green, before I go to a complicated
  165. programme for you to type in. I should
  166. tell you something, a short hand way
  167. to write CHR$, which is cH. Well that
  168. is how it looks in lower case. Upper
  169. case would have the capital C and a
  170. vertical bar. Still have to type in
  171. the () things with the number between
  172. them though.
  173.  
  174. Next is a colour bar programme. I have
  175. a few things to say before you have a
  176. go at typing it into the C=. Running
  177. this will create a series of reverse
  178. video colour bars on the screen. They
  179. will run till you press the run/stop
  180. key, only does the first 8 colours of
  181. the commodores 16 and uses the chr$
  182. codes. If you feel like experimenting
  183. and have the chart, feel free to
  184. expand this to the full16 colours. We
  185. have covered the rudiments for how to
  186. do that except for a command that is
  187. new to us at this point and I will get
  188. to that afterwards. I did make this as
  189. the 16 colours the tool that I use to
  190. test the colour chip and monitors when
  191. they come into my collection.
  192.  
  193. The final part is a lesson on editing;
  194. you will see that there are many lines
  195. here that are close to being the same.
  196. OK lines 40-110. I'll explain about
  197. editing, after you see the programme,
  198. but wait to type it in, and you will
  199. save some fingers.
  200. Type NEW then press RETURN
  201.  
  202. 1 REM AUTOMATIC COLOR BARS
  203. 5 ?CHR$(147)
  204. 10 ?CHR$(18);"   ";
  205. 20 CL=INT(8*RND(1))+1
  206. 30 ON CL GOTO 40.50,60,70,80,90,100,
  207. 110
  208. 40 ?CHR$(5);:GOTO10
  209. 50 ?CHR$(28);:GOTO10
  210. 60 ?CHR$(30);:GOTO10
  211. 70 ?CHR$(31);:GOTO10
  212. 80 ?CHR$(144);:GOTO10
  213. 90 ?CHR$(156);:GOTO10
  214. 100 ?CHR$(158);:GOTO10
  215. 110 ?CHR$(159);:GOTO10
  216.  
  217. Before any explanation lets save your
  218. fingers editing time with the C=. Type
  219. in line 40 you can see how much it is
  220. the same as the other lines below it,
  221. so how to avoid typing all that drenn
  222. over and over again? Well after you
  223. type line 40. Oh yeah make absolutely
  224. certain that you hit the return key
  225. [lightly of course] after you complete
  226. each line. Return takes you to just
  227. underneath the 4 in 40, cursor up to
  228. that 4, and now type a 5 over it.
  229. Right the line now reads 50, don't
  230. panic yet cursor over to the 5 in the
  231. () symbols. Use a shifted inst/del key
  232. this makes a space. Creating a two
  233. character area in between the ()
  234. symbols. Type in the 2 and right over
  235. the 5 you see there type the 8. Now
  236. the line reads right for line 50.
  237. Press return and then cursor up,
  238. change the 5 to a 6. Type over the 28
  239. making changing it to 30 press RETURN
  240. and you have line 60 done. Repeat this
  241. till you have all the lines completed.
  242.  
  243. Panic time? No not really, if you did
  244. it as above, then you will be sitting
  245. on line 110 with the cursor under the
  246. 1 sure you are panicking about the
  247. other lines, so I want you to type
  248. either LIST then press return. Why
  249. there is the complete programme!
  250. Editing here is that you log in or
  251. record the line as written with the
  252. line number, each time you press
  253. return you add the line to memory. You
  254. can also type in line numbers out of
  255. linear sequence but they will all show
  256. up in the programme in nice neat
  257. linear number fashion when the program
  258. is Listed to screen.
  259.  
  260. So what is happening in this
  261. programme? After you run it you will
  262. see the 5 space colour bars go across
  263. the screen and down one line, pretty
  264. fast considering the speed of the
  265. machine <VBG>. Well we have covered
  266. line 1, the REM statement. We have
  267. covered line 5 the clear home CHR$.
  268. Line 10 is a tad bit different, here
  269. you tell it to print a character
  270. string; this one being 18, that is the
  271. command to turn on reverse video with
  272. a character string. A semicolon
  273. follows, so things will stay on the
  274. same line and be connected, that is
  275. why the colour bars are butted against
  276. each other, no spaces and no one
  277. colour bar, then it drops to the next
  278. line. In the quotes are 5 spaces, just
  279. a number I took from the book, you can
  280. make it larger or smaller for some
  281. interesting effects. At 20 we have
  282. that variable and a random number
  283. generator, as you see the number in
  284. there is 8, so we are creating 8
  285. separate numbers. Line 30 has a new
  286. command, the ON command, before I go
  287. to the how it works, think what the
  288. programme would look like if you used
  289. IF THEN statements.
  290.  
  291. 40 IF CL=1 THEN?CHR$(5):GOTO10
  292.  
  293. Right you would have to do that for
  294. each of the 8 lines, of course you
  295. would be writing 8 lines of IF THEN
  296. and a line about getting the CL, and
  297. well you can see it is confusing.
  298. Using the ON command is a little hard
  299. and confusing at first, the majority
  300. of people in programming Basic that I
  301. respect, advocate the ON command.
  302. Saying that, here is how it works, as
  303. simply as I can state. The Line is
  304. saying that on the CL variable, the
  305. computer is to goto a specific line.
  306. So lets say that the random number
  307. generator creates for CL a 7, we do
  308. what and where? Right I understand the
  309. confusion, I had that problem for a
  310. long time a mental block. What helped
  311. me is to count the things in the rest
  312. of the line, here it reads 40-110.
  313. Yeah those commas are mandatory. Hmm
  314. seems to be that there are 8 of them,
  315. well the generator makes only 8
  316. numbers. The Amount of things to goto
  317. must equal the amount created with the
  318. generator. Personally I got messed up
  319. with the numbers and other things for
  320. the goto part, blocking me from
  321. gaining even this little understanding.
  322.  
  323. Ok so back to my example, the
  324. generator has created for the variable
  325. CL a number 7, So on CL, or read that
  326. as ON 7 GOTO 100, this is because that
  327. is the 7th number in the line. Got it,
  328. generate a 4 and it goes to the 4th
  329. number in the line. 1 would be the
  330. first number, and so forth. Don't ask
  331. how long it took for me to understand
  332. that one. <S> OK you are brighter than
  333. me, bet you can see that in certain
  334. forms of games, you can have the ON
  335. statement take the programme to a
  336. print statement and have specific text
  337. appear.
  338.  
  339. After the above example, the book now
  340. on page 60 starts at the bottom with
  341. the idea of PEEKS and POKES do.
  342. Honestly this is a hard one for me,
  343. not that I don't know what they are, I
  344. don't know WHAT they are. Got you
  345. confused yet? <G> Well OK what I mean
  346. is that I know that a POKE or in short
  347. hand a pO, Sticks something into the
  348. computer memory, the book uses the
  349. idea of boxes. Other books talk about
  350. egg crates, and others the old
  351. fashioned roll top desk with all the
  352. little letter sized pigeon holes, all
  353. trying to give you a visual of a lots
  354. of storage areas that you can put a
  355. something into. A PEEK or in short
  356. hand pE. Is looking in as they say, to
  357. a box or pigeon hole, and shows you
  358. what is in there at that moment. Got
  359. that part in the bare basics, now what
  360. or where these places are is not in my
  361. understanding at this time.
  362.  
  363.  Showing the vacuum of my brain above.
  364. We shall talk more on this in the next
  365. session
  366.  
  367.           CONTINUED NEXT MONTH
  368.  
  369.